package main

import (
	"fmt"
)

type Inter1 interface {
	Read()
}
type User struct {
	Name string
}

func (user *User) Read() {
	fmt.Println("123")
}

func Test(tt Inter1)  {
	tt.Read()
}

func main() {
	u := &User{
		Name: "lwenjim",
	}
	Test(u)


	//c := make(chan int)
	//go func() {
	//	time.Sleep(time.Second * 5)
	//	c <- 1
	//	close(c)
	//}()
	//func(){
	//	<-c
	//	fmt.Println("ok")
	//}()


	//user := &User{
	//	Name: "lwenjim",
	//}
	//fmt.Println(user.Name)

	//conn, _ := redis.Dial("tcp", "localhost:6379")
	//reply,err := redis.String(conn.Do("hget", "user", 333))
	//fmt.Println(reply)
	//fmt.Println(err)

	//fmt.Println("ok")
	//var pkgLen uint32 = 1000000
	//var bytes [4]byte
	//binary.BigEndian.PutUint32(bytes[0:4], pkgLen)
	//fmt.Println(bytes)

	//pool := &redis.Pool{
	//	MaxActive:   0,
	//	MaxIdle:     8,
	//	IdleTimeout: 100,
	//	Dial: func() (redis.Conn, error) {
	//		return redis.Dial("tcp", "127.0.0.1:6379")
	//	},
	//}
	//pool.Close()

	//fmt.Println()
	//data ,err	:= redis.String(pool.Get().Do("hget", "new-name24", "name"))
	//if err != nil {
	//	fmt.Printf("err=%v\n", err)
	//	return
	//}
	//fmt.Println(data)

	//fmt.Println(data)

	//conn, err := redis.Dial("tcp", "127.0.0.1:6379")
	//if err != nil {=
	//	fmt.Println("redis connected failed err=", err)
	//}
	//defer conn.Close()

	//_, err = conn.Do("hset", "new-name", "name", "lwenjim")
	//if err != nil {
	//	fmt.Printf("redis.hset failed err=%v\n", err)
	//}
	//_, err = conn.Do("hset", "new-name", "age", "123")
	//if err != nil {
	//	fmt.Printf("redis.hset failed err=%v\n", err)
	//}
	//
	//data, err := redis.String(conn.Do("hget", "new-name", "name"))
	//if err != nil {
	//	fmt.Printf("redis.hget failed err=%v\n", err)
	//}

	//_, err = conn.Do("hmset", "new-name2", "name", "lwenjim2", "age", 12)
	//if err != nil {
	//	fmt.Printf("redis.hset failed err=%v\n", err)
	//}
	//
	//data, err := redis.Strings(conn.Do("hgetall", "new-name2"))
	//if err != nil {
	//	fmt.Printf("redis.hget failed err=%v\n", err)
	//}
	//
	//fmt.Println(data)
}
